package com.example.wanbaqian.adapter;

import android.content.Context;
import android.view.View;

import com.example.wanbaqian.R;
import com.example.wanbaqian.bean.CouponInfo;
import com.example.wanbaqian.customView.CardView;
import com.example.wanbaqian.utils.TimeUtils;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by Administrator on 2017/4/6 0006.
 * 发现优惠券适配器
 */

public class FindFreeAdapter extends CommonAdapter<CouponInfo> {

    public FindFreeAdapter(final Context context, List<CouponInfo> datas) {
        super(context, R.layout.item_findfree, datas);
    }

    @Override
    public void onViewHolderCreated(ViewHolder holder, View itemView) {
        super.onViewHolderCreated(holder, itemView);
        AutoUtils.autoSize(itemView);
    }
//    @Override
//    protected void convertEmpty(ViewHolder holder) {
//        super.convertEmpty(holder);
//        TextView top=holder.getView(R.id.top);
//        top.setVisibility(View.VISIBLE);
//        top.setText("你还没有优惠券\n分享好友参加活动既有机会获得优惠券");
//        top.setPadding(0,300,0,70);
//        top.setTextSize(30);
//    }

    @Override
    protected void convert(ViewHolder holder, final CouponInfo item, int position) {
        holder.setVisible(R.id.top, position == 0);
        ((CardView) holder.getView(R.id.cv_free)).setMoney(item.getCoupon_value()).setIsused(item.getUse_flag().equals("1")).Build();
        holder.setText(R.id.tv_money, "有效期 " + TimeUtils.getStrTime(item.getExpire_time(), ""));
    }

}

